<?php

    define('ABSOLUTE_SERVER_REMOTE_ADDR','http://'.$_SERVER['REMOTE_ADDR'].'/');
    define('ABSOLUTE_SERVER_DOCUMENT_ROOT',$_SERVER['DOCUMENT_ROOT'].'/');
    define('LINK_COOKIE',"ows_link_cookie");


//-------------------------------------------------------------------
//Nazov:		Print_Product_Link
//Popis:		Vytvorenie linku pre tovar
//-------------------------------------------------------------------
function Product_Link($ProductID){
	return "http://".$_SERVER["HTTP_HOST"]."/index.php?Link_Value=$ProductID";
}


//-------------------------------------------------------------------
//Nazov:		Generate_Select_SQL
//Popis:		Vytvorenie SQL zo zoznamu odkazov
//-------------------------------------------------------------------
function Product_Link_Generate_Select_SQL($ID_List){
	$Arr = explode("-",$ID_List);
	$Arr_Count = count($Arr);
		
	if(($ID_List=="") or ($Arr_Count<1)) return "";
	
	for($i=0;$i<$Arr_Count;$i++)
		$where .= "(ID=".$Arr[$i].") OR ";
	
	$where = substr($where,0,-4);	
	return "SELECT * FROM products WHERE ($where)";
}


function ID_List_Count($ID_List){
	$Arr = explode("-",$ID_List);
	$Arr_Count = count($Arr);

	return $Arr_Count;
}


//-------------------------------------------------------------------
//Nazov:		Print_Mail_Button
//Popis:		Zobrazenie tlacitka pri tovare pre otvorenie stranky na odoslanie mailu
//-------------------------------------------------------------------
function Print_Mail_Button($ProductID){/*
  	print "	 					
		<form action=\"admin/modules/product_link/product_link.php\" target=\"products\" method=\"post\">
			<input type=\"hidden\" value=\"".$ProductCode."\" name=\"ProductCode\" />			
			<input type=\"image\" src=\"admin/modules/product_link/mail.jpg\" value=\"submit\" alt=\"Odosla� e-mailom\" style=\"border:0px;\"/>
		</form>	 					
	";*/
	
	print "
		<input type=\"image\" src=\"admin/modules/product_link/mail.jpg\" value=\"button\" alt=\"Odosla� e-mailom\" style=\"border:0px;\"		
			onClick=\"javascript:window.open('admin/modules/product_link/product_link.php?ProductID=$ProductID','product_link_mail','width=630px,height=410px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"		
		/>
	";
}

//-------------------------------------------------------------------
//Nazov:		Send_Mail
//Popis:		Odoslanie e-mailu
//-------------------------------------------------------------------
function Send_Mail($Address,$Caption,$Text){
	return mail($Address,$Caption,$Text);
}

function SetLinkCookie($Link_Value){
	setcookie(LINK_COOKIE,$Link_Value);
}

function GetLinkCookie(){
	if (isset($_COOKIE[LINK_COOKIE]))
		return $_COOKIE[LINK_COOKIE];
	else
		return "";
}

function UnsetLinkCookie(){
	if (isset($_COOKIE[LINK_COOKIE]))
		return setcookie(LINK_COOKIE,"",time() - 3600);
}

/*
function CreateLinkListFromShopBasket($CookieName){
	$result = "";
    if (isset($_COOKIE[$CookieName])){
    	$ShopBasket = $_COOKIE[$CookieName];
        while (DecodeCookie($ShopBasket,$ID,$Count))
        {	
        	$result .= $ID."+";//Product_Link($sql_arr[0])."\n";
        }
    }
    $result = substr($result,0,-2);
    return $result;//$result;
}
*/
?>